home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-gnome2-desktop / examples / gnomeprint / example_08.py < prev    next >
Encoding:
Python Source  |  2009-03-14  |  1.7 KB  |  67 lines

  1. #! /usr/bin/env python
  2.  
  3. # *  example_08.c: sample gnome-print code
  4. # *
  5. # *  This program is free software; you can redistribute it and/or
  6. # *  modify it under the terms of the GNU Library General Public License
  7. # *  as published by the Free Software Foundation; either version 2 of
  8. # *  the License, or (at your option) any later version.
  9. # *
  10. # *  This program is distributed in the hope that it will be useful,
  11. # *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # *  GNU Library General Public License for more details.
  14. # *
  15. # *  You should have received a copy of the GNU Library General Public
  16. # *  License along with this program; if not, write to the Free Software
  17. # *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. # *
  19. # *  Authors:
  20. # *    Chema Celorio <chema@ximian.com>
  21. #    Python conversion:
  22. #      Gustavo J. A. M. Carneiro <gustavo@users.sf.net>
  23. # *
  24. # *  Copyright (C) 2002 Ximian Inc. and authors
  25. # *
  26. # */
  27.  
  28. #/*
  29. # * See README
  30. # */
  31.  
  32. import pygtk; pygtk.require("2.0")
  33. import gnomeprint, gnomeprint.ui
  34.  
  35. def my_draw(gpc):
  36.     gpc.beginpage("1")
  37.  
  38.     gpc.moveto(100, 100)
  39.     gpc.lineto(200, 200)
  40.     gpc.stroke()
  41.     
  42.     gpc.showpage()
  43.  
  44.  
  45. def my_print():
  46.     # Create the objects */
  47.     job    = gnomeprint.Job(gnomeprint.config_default())
  48.     dialog = gnomeprint.ui.Dialog(job, "Sample print dialog", 0)
  49.     gpc    = job.get_context()
  50.     config = job.get_config()
  51.  
  52.     # Run the dialog */
  53.     response = dialog.run()
  54.     if response != gnomeprint.ui.DIALOG_RESPONSE_PRINT:
  55.     print "Printing was canceled"
  56.     return
  57.     
  58.     # We don't print, we only dump the info 
  59.     my_draw(gpc)
  60.     config.dump()
  61.     job.close()
  62.  
  63.     
  64. my_print ();
  65. print "Done..."
  66.  
  67.